﻿@model DotNet.Model.MyEntity.Base_User
<style type="text/css" media="screen">
    .my-uploadify-button
    {
        background: none;
        border: none;
        text-shadow: none;
        border-radius: 0;
    }
    
    .uploadify:hover .my-uploadify-button
    {
        background: none;
        border: none;
    }
    
    .fileQueue
    {
        width: 400px;
        height: 50px;
        overflow: auto;
        border: 1px solid #E5E5E5;
        margin-bottom: 10px;
    }
</style>
<link href="/Scripts/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/uploadify/swfobject.js" type="text/javascript"> </script>
<script src="/Scripts/uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript"> </script>
<script type="text/javascript">
    //绑定上传的方法
    $(function () {
        $('#signedSelect').uploadify({
            'uploader': '/Scripts/uploadify/uploadify.swf?id=' + (new Date()).getTime(),
            'script': '/Permission/User/UploadSigned/',
            'method': 'POST',
            'scriptData': { userId: '@Model.Id' },
            'cancelImg': '/Scripts/uploadify/cancel.png',
            'folder': 'Files',
            'queueID': 'fileQueue',
            'wmode': 'transparent',
            'fileDesc': '*.jpg;*.jpeg;*.gif;*.png;',
            'fileExt': '*.jpg;*.jpeg;*.gif;*.png;',
            'sizeLimit': '2000000', //20K
            'height': '30',
            'removeCompleted': true,
            'buttonText': "选择文件",
            'multi': false,
            'onComplete': function (event, queueID, fileObj, response, data) {
                var json = eval("(" + response + ")");
                $("#imgSigned").attr("src", json.SignedPassword + "?flag=" + (new Date()).getTime());
            },
            'onSelect': function (e, queueId, fileObj) {
                if (fileObj.size > 1024 * 200) {
                    alertMsg.info(fileObj.name + "文件过大！已被过滤");
                    $(this).uploadifyCancel(queueId);
                }
            },
            'onError': function (event, queueID, fileObj, errorObj) {
                alertMsg.warn(errorObj.type + "Error:" + errorObj.info);
            }
        });
    });
    function deletePic_user(uid) {
        if ($("#imgSigned").attr("src") == null || $("#imgSigned").attr("src")=="")
           return false;
        alertMsg.confirm("您确定要删除吗？", {
            okCall: function () {
                $.post("/Permission/User/DeletePic", { "uid": uid }, function (json) {
                    $("#imgSigned").removeAttr("src");
                }, "json");
            }
        });
    }
</script>
<div class="pageContentD">
    <div class="pageFormContent" layouth="60">
        <input  id="signedSelect" type="file" name="image" />
        <input type="button" class="btn btn-info btn-sm" value="上传" onclick="$('#signedSelect').uploadifyUpload();" />
        <input type="button" class="btn btn-warning btn-sm" value="删除" onclick="javascript:deletePic_user(@Model.Id);" />
        <div id="fileQueue" class="fileQueue">
        </div>
        <div id="showPic">
            <img id="imgSigned" @Html.Raw("src='" + Model.SignedPassword +"?flag="+new Random().NextDouble()+ "'")  />
        </div>
    </div>
    <div class='formBar'>
        <ul>
            @*<li>
                <button type="button" class="btn btn-info btn-sm" id="btnNext_Workflow_Ctrl_Select">
                    下一步</button>
            </li>*@
            <li>
                <button type="button" class="close btn btn-default btn-sm">
                    关闭</button>
            </li>
        </ul>
    </div>
</div>
